package com.loren.demo04.simple;

import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/demo1")
public class RedisDemo1Controller {

    private final RedisTemplate<String, String> redisTemplate;

    @GetMapping
    public String demo() {
        this.redisTemplate.opsForValue().set("demo1:aaa", "hello world");
        this.redisTemplate.opsForList().rightPush("demo1:list", "aaa");
        this.redisTemplate.opsForList().rightPush("demo1:list", "bbb");
        return this.redisTemplate.opsForValue().get("demo1:aaa");
    }
}
